package com.ssy.lingxi.platform.manage.serviceimpl;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.constant.CommonBooleanEnum;
import com.ssy.lingxi.platform.manage.entity.base.OnlineService;
import com.ssy.lingxi.platform.manage.model.response.OnlineServiceDetailRes;
import com.ssy.lingxi.platform.manage.repository.OnlineServiceRepository;
import com.ssy.lingxi.platform.manage.service.IOnlineServiceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author wyx
 * @version 2.0.0
 * @date 2021-11-16
 */
@Service
public class OnlineServiceServiceImpl implements IOnlineServiceService {
    @Resource
    private OnlineServiceRepository onlineServiceRepository;


    /**
     * 获取在线客服配置信息
     * @return 操作结果
     */
    @Override
    public Wrapper<OnlineServiceDetailRes> findConfig() {
        OnlineService onlineService = onlineServiceRepository.findFirstByStatus(CommonBooleanEnum.YES.getCode());
        if (onlineService == null) {
            return Wrapper.success();
        }
        return Wrapper.success(new OnlineServiceDetailRes(onlineService.getId(), onlineService.getPlatformName(), onlineService.getType(), onlineService.getParamConfigList()));
    }
}
